Fail configuration if libusb-1.0 is not found (#564)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Mon, 25 May 2020 17:52:58 +0000 (11:52 -0600)
committerGitHub <noreply@github.com>
Mon, 25 May 2020 17:52:58 +0000 (11:52 -0600)
* have configure fail if libusb is enabled and not found.

* correct indentation in configure.

configure
configure.ac

index 375a7fdc1bbd06874a204fda84e76ee443e9bd23..8819601ce0548d4eb2ac31a40503e2971e78062d 100755 (executable)
--- a/configure
+++ b/configure
@@ -728,6 +728,7 @@ enable_csv
 enable_most
 enable_filters
 with_zlib
+with_libusb
 with_doc
 '
       ac_precious_vars='build_alias
@@ -1377,6 +1378,7 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-zlib=(included)|system|no
 
+  --without-libusb        disable support for libusb
   --with-doc=DIR          Path where the documentation will be stored.
 
 Some influential environment variables:
@@ -6261,17 +6263,21 @@ fi
   *) :
 
        GBSER=gbser_posix.o
-       { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb-1.0" >&5
-$as_echo_n "checking for libusb-1.0... " >&6; }
+
+# Check whether --with-libusb was given.
+if test "${with_libusb+set}" = set; then :
+  withval=$with_libusb;
+else
+  with_libusb=yes
+fi
+
        if test "$with_libusb" = "no"; then :
 
-               { $as_echo "$as_me:${as_lineno-$LINENO}: result: check not done" >&5
-$as_echo "check not done" >&6; }
                OSJEEPS=jeeps/gpsusbstub.o
 
 else
 
-
+    # Die if libusb-1.0 not found. This prevents link failures later.
                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libusb_init in -lusb-1.0" >&5
 $as_echo_n "checking for libusb_init in -lusb-1.0... " >&6; }
 if ${ac_cv_lib_usb_1_0_libusb_init+:} false; then :
@@ -6315,6 +6321,11 @@ _ACEOF
 
   LIBS="-lusb-1.0 $LIBS"
 
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "libusb-1.0 not found (--without-libusb to disable)
+See \`config.log' for more details" "$LINENO" 5; }
 fi
 
                OSJEEPS=jeeps/gpslibusb.o
index 4a03e867c2656b3d34b90be376822ca62bd87af5..a6b9ae01dde5b31e7c169d876c679d842d731414 100644 (file)
@@ -229,13 +229,16 @@ AS_CASE(["$target"], [*-*-cygwin* | *-*-mingw32*], [
        QT_SYSINC_OPT="-iframework"
 ], [
        GBSER=gbser_posix.o
-       AC_MSG_CHECKING(for libusb-1.0)
+       AC_ARG_WITH([libusb],
+               [AS_HELP_STRING([--without-libusb], [disable support for libusb])],
+               [],
+               [with_libusb=yes])
        AS_IF([test "$with_libusb" = "no"], [
-               AC_MSG_RESULT(check not done)
                OSJEEPS=jeeps/gpsusbstub.o
        ], [
-
-               AC_CHECK_LIB([usb-1.0], [libusb_init])
+    # Die if libusb-1.0 not found. This prevents link failures later.
+               AC_CHECK_LIB([usb-1.0], [libusb_init], [],
+                       [AC_MSG_FAILURE(libusb-1.0 not found (--without-libusb to disable))])
                OSJEEPS=jeeps/gpslibusb.o
        ])
 ])